<?php
    session_start();		
    ob_start();
    $lk_kodekota = $_SESSION["KOTA_VAL"];
?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <?
function generateSelect($name = '', $options = array()) {
	$html = '<select name="'.$name.'">';
	foreach ($options as $option => $value) {
		$html .= '<option value='.$value.'>'.$option.'</option>';
	}
	$html .= '</select>';
 	return $html;
}
?>
</head>
<body>
<?php
		
    $data=$_GET["q"];
    //echo $data;
    if($data=="XX")
        $data = $_SESSION["PROP_VAL"];
    include('class.mysql.php');
    $mydb = new mysql();
    $connection = $mydb->Connect();
    
    /*ambil data kota / kabupaten terpilih (awal)*/
    $sql="select kabupaten,kode,kode_prop from kabupaten where kode_prop='$data' and kode='$lk_kodekota'";
    //echo "$sql";	
    $query = $mydb->Query($sql);
    $num = $mydb->FetchNum($query);
    //$kabupaten[]="Pilih kota2";
    if($array= mysql_fetch_row($query))
    {
        $kabupaten[]=$array[0];
        $kode[]=$array[1];
    }

    /*Abil list kota / propinsi*/
    $sql="select kabupaten,kode,kode_prop from kabupaten where kode_prop='$data'";
    //echo "$sql";	
    $query = $mydb->Query($sql);
    $num = $mydb->FetchNum($query);
    //$kabupaten[]="Pilih kota2";
    while($array= mysql_fetch_row($query))
    {
        $kabupaten[]=$array[0];
        $kode[]=$array[1];
    }
    
    //echo $data.$kabupaten[2];
    //ob_end_flush();

    $stTemp = '<select name="kd_pend_terakhir" onchange="update_noreg(this.value)" value='.$kode.' disabled >';
    $i=0;
    while($kode[$i]!='')
    {
        $stTemp .= '<option value="'. $kode[$i].'">' . $kabupaten[$i] . '</option>';
        $i++;
    }
    $stTemp .= '</select>';
    echo    $stTemp;
    ob_end_flush();
?>
</body>

